package framework.jackson;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import spring.DI.methodDI.Dog;
import spring.factoryBean.ColorEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.StringJoiner;

/**
 * @author ME
 * @date 2021/1/17
 */
public class Person {
    private List<Long> ids;

    @JsonSerialize(using = JsonSerializer.None.class)
    // @JsonRawValue// 序列化时属性值不会被转义或者加引号，把原始内容作为序列化的内容
    private String name;

    /**
     * 配置 @JsonProperty 后，序列化、反序列化都会使用指定的属性名
     */
    @JsonProperty("ag")
    private Integer age;

    private GenderEnum gender;

    private ColorEnum colorEnum;

    private BigDecimal money;

    private List<String> hobbies;

    // 测试内置泛型类型

    private Dog dog;

    public List<Long> getIds() {
        return ids;
    }

    public void setIds(List<Long> ids) {
        this.ids = ids;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public GenderEnum getGender() {
        return gender;
    }

    public void setGender(GenderEnum gender) {
        this.gender = gender;
    }

    public ColorEnum getColorEnum() {
        return colorEnum;
    }

    public void setColorEnum(ColorEnum colorEnum) {
        this.colorEnum = colorEnum;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    @Override
    public String toString() {
        StringJoiner joiner = new StringJoiner(", ", Person.class.getSimpleName() + "[", "]")
                .add("ids=" + ids)
                .add("name='" + name + "'")
                .add("age=" + age);
        if (gender != null) {
            joiner.add("gender=" + gender);
        }
        joiner.add("colorEnum=" + colorEnum)
                .add("money=" + money)
                .add("hobbies=" + hobbies)
                .add("dog=" + dog);

        return joiner.toString();
    }
}
